package com.hqyj.controller;


import com.hqyj.pojo.DepartmentPermission;
import com.hqyj.service.IDepartmentPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * <p>
 * 用户_权限表 前端控制器
 * </p>
 *
 * @author rock
 * @since 2021-10-21
 */
@RestController
@RequestMapping("/departmentPermission")
public class DepartmentPermissionController {

    @Autowired
    IDepartmentPermissionService departmentPermissionService;

    @RequestMapping("/departmentPermissionList")
    public HashMap<String,Object> departmentPermissionList(DepartmentPermission departmentPermission){
        HashMap<String,Object> map = departmentPermissionService.queryAll(departmentPermission);
        return map;
    }

    @RequestMapping("/addDepartmentPermission")
    public HashMap<String, Object> addPermission(Model model, DepartmentPermission departmentPermission){
        HashMap<String, Object> map = departmentPermissionService.addDP(departmentPermission);
        if(map.get("info").equals("保存成功")){
            model.addAttribute("info","保存成功");
        }else {
            model.addAttribute("info", "保存失败");
        }
        return map;
    }

    @RequestMapping("/delDepartmentPermission")
    public HashMap<String, Object> delPermission(Integer id){
        return departmentPermissionService.del(id);
    }
}

